fn main() {
    println!("Hello, world!");

    write_response(200,
                   "OK",
                   vec![Header{key: "Content-Type".to_string(), value:"text/html".to_string()}])

}

fn write_response(status:u16, body: &str, headers: Vec<Header>){
    let resp = HttpResponse();
    let mut resp = resp.status_line(200, "OK");
    for h in headers {
        resp.header(h.key.as_str(), h.value.as_str());
    }
    resp.body(body);
 }


// http://cliffle.com/blog/rust-typestate/
struct HttpResponse();
struct HttpResponseAfterStatus();
struct Header{
    key: String,
    value: String
}
impl HttpResponse {
    fn status_line(self, code: u8, message: &str) -> HttpResponseAfterStatus {
        HttpResponseAfterStatus()
    }
}

impl HttpResponseAfterStatus {
    fn header(&mut self, key: &str, value: &str) {
        // ...
    }
    fn body(self, text: &str) {

    }
}
